package com.zrrd.mapper;

import com.zrrd.pojo.Classes;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author WanJl
 * @version 1.0
 * @title ManyToManyMapper
 * @description
 * @create 2024/1/23 15:55
 */
public interface OneToManyMapper02 {
    @Select("SELECT * FROM jms2301_db02.classes")
    @Results({
            @Result(column = "id",property = "id"),
            @Result(column = "name",property = "name"),
            @Result(
                    property = "students",//被包含对象的变量名称
                    javaType = List.class,//被包含对象的实际数据类型
                    column = "cid",//根据查询出来的Classes表里面的id字段去查询Student表。
                    /**
                     * many、@Many 一对多查询的固定写法
                     * select属性，指定要调用哪个接口中的哪个查询方法
                    */
                    many = @Many(select = "com.zrrd.mapper.StudentMapper.selectByCid")
            )
    })
    List<Classes> queryAll();
}
